package com.gaoyang.thread;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gaoyang.util.HttpUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;

public class PiaoThread implements Callable {

    String ticketNum = "";
    String ticketPwd = "";


    public PiaoThread(String ticketNum, String ticketPwd) {
        this.ticketNum = ticketNum;
        this.ticketPwd = ticketPwd;
    }

    @Override
    public String call() throws Exception {
        String logOutput = "";
        Map<String, String> paramMap = new HashMap<String, String>();
        paramMap.put("cmd", "22");
        paramMap.put("subcmd", "22");
        paramMap.put("checkNo", ticketNum);
        paramMap.put("pass", ticketPwd);
        paramMap.put("outerOrderId", "22");
//        Thread.sleep((long)(Math.random() * 1000));
//        logOutput = "threadName=" + Thread.currentThread().getName();
        String returnStr = HttpUtils.postUrl("https://m.epiaom.com/ajax/userCenter.php", paramMap);
        JSONObject jsonObject = JSON.parseObject(returnStr);
        boolean flag = (Boolean) jsonObject.get("flag");
        String msg = (String) jsonObject.get("msg");
        logOutput = ticketNum + " " + ticketPwd + " " + flag + " " + msg;
        return logOutput;
    }

}